function fetchFromThepaper(url, bd) {
    var con = org.jsoup.Jsoup.connect(url);
    con.header("Accept", "application/json");
    con.header("Content-Type", "application/json");
    con.header("Origin", "https://m.thepaper.cn");
    con.header("Referer", "https://m.thepaper.cn/");
    con.header("User-Agent", "Mozilla/5.0 (Linux; Android 11; Pixel 3 XL Build/RQ3A.211001.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/102.0.4988.0 Mobile Safari/537.36 SearchCraft/3.9.2 (Baidu; P1 11)");
    con.requestBody(JSON.stringify(bd));
    con.ignoreContentType(true);
    return con.post().body().text();
}

function fetchByPost(url, bd) {
    var con = org.jsoup.Jsoup.connect(url);
    con.requestBody(JSON.stringify(bd));
    con.ignoreContentType(true);
    return con.post().body().text();
}

function formatDate2(inputTime) {
    var date = new Date(inputTime);
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    return y + '-' + m + '-' + d;
};

function formatDate(now) {
    var time = formatDate2(now)
    var date1 = new Date(now)
    var date2 = new Date()
    var date3 = date2.getTime() - date1.getTime()
    var days = Math.floor(date3 / (24 * 3600 * 1000))
    var leave1 = date3 % (24 * 3600 * 1000)
    var hours = Math.floor(leave1 / (3600 * 1000))
    var leave2 = leave1 % (3600 * 1000)
    var minutes = Math.floor(leave2 / (60 * 1000))
    var leave3 = leave2 % (60 * 1000)
    if (days < 1 && hours < 1) { return minutes + "分前" } else if (days < 1) { return hours + "小时 " + minutes + "分前" } else {
        if (days < 7) {
            return days + "天 " + hours + "小时前 "
        } else { return time }
    }
}

function formatTime(seconds) {
    if (isNaN(seconds) || seconds < 0) return "0:00"; // 处理无效输入

    const hours = Math.floor(seconds / 3600);
    const minutes = Math.floor((seconds % 3600) / 60);
    const remainingSeconds = seconds % 60;

    // 补零函数
    const pad = (num) => num < 10 ? `0${num}` : num;

    // 根据小时数动态选择格式
    if (hours > 0) {
        return `${hours}:${pad(minutes)}:${pad(remainingSeconds)}`;
    } else {
        return `${minutes}:${pad(remainingSeconds)}`;
    }
}
